import * as actionTypes from './actionTypes';
import axios from 'axios';

// 获取banner数据
export const getBanners = () => {
  return (dispatch) => {
    axios.get('http://localhost:3000/banner').then(res => {
      const banners = res.data.banners
      const action = {
        type: actionTypes.GET_BANNERS,
        banners
      }
      dispatch(action)
    })
  }
}

// 获取推荐歌单数据
export const getRecommendSheet = () => {
  return (dispatch) => {
    axios.get('http://localhost:3000/personalized?limit=24').then(res => {
      const sheets = res.data.result
      const action = {
        type: actionTypes.GET_RECOMMEND_SHEET,
        sheets
      }
      dispatch(action);
    })
  }
}